(function($){
         var privataFun=function(){
            //调用私有方法
         }
         var pageSwitch=(function(){
              function pageSwitch(element,options){
                  this.settings=$.extend(true,$.fn.pageSwitch.defaults,options||{});
                  this.element=element;
                  this.init();
              }
              pageSwich.prototype={
                  init:function(){
                     //这里的init属于公用方法
                     var me =this;
                     me.selectors=me.settings.selectors;
                     me.sections=me.selectors.sections;
                     me.section=me.selectors.section;

                     me.direction=me.settings.direction=="vertical"?true:false;
                     me.pagesCount=me.pagesCount();
                     me.index=(me.settings.index>=0 && me.settings.index<pagesCount)? me.settings.index:0;
                  
                     if(!me.direction){
                        me._initLayout();
                     }

                     if(me.settings.pagination){
                        me._initPaging();
                        }
                        me._initEvent(); //重点
                     },
                     //获取滑动页面数量
                  pagesCount:function(){
                       return this.section.length;
                  },
                   //获取滑动的宽度(横屏滑动)或高度(竖屏滑动)
                  switchLength:function(){
                    return this.direction ? this.element.height() :this.element.width(); 
                  },
                  //主要针对横屏情况进行页面布局
                  _initLayout:function(){
                    var me=this;
                    var width=(me.pagesCount*100)+"%",
                        cellWidth=(100/me.pagesCount).toFixed(2)+"%";
                    me.sections.width(width);
                    me.section.width(cellWidth).css("float","left");
                  },
                  //实现分页的dom结构及CSS样式
                  _initPaging:function(){
                    var me=this,
                        pagesClass=me.selectors.page.substring(1);
                        activeClass=me.selectors.active.substring(1);
                    var  pageHtml="<ul class="+pagesClass+">";
                    for (var i=0;i<me.pagesCount;i++){
                        pageHtml+="<li></li>";
                    }
                    me.element.append(pageHtml);
                    var pages=me.element.find(me.selectors.page);
                    me.pageItem=pages.find("li");
                    me.pageItem.eq(me.index).addClass(me.activeClass);

                    if(me.direction){
                        pages.addClass("vertical");
                    }else{
                        pages.addClass("horizontal");
                    }
                  },
                  //初始化插件事件
                  _initEvent:function(){
                    var  me =this;
                    me.element.on("click", me.selectors.pages + "li",function(){
                         me.index =$(this).index();
                         me._scrollpage();
                    })
                  }
              };
              return pageSwitch;
         })();
         $.fn.pageSwitch=function(options){
             return this.each(function(){
                  var me =$(this),
                      instance=me.data("pageSwitch");
                    if(!instance){
                        instance=new pageSwitch(me,options);
                        me.data("pageSwitch",instance);
                    }
                    if($.type(options)==="string") return instance[options]();
                    $("div").pageSwitch("init");
             });

         }
         $.fn.pageSwitch.defaults={
                   selectors:{
                           sections:”.sections”,
                           section:”.section”,
                           page:".page",
                           active:".active"
                        },
                        index:0,
                        //从第几页开始,注意不能小于0或者大于3
                        easing:"ease",
                        //动画效果
                        duration:500,
                        loop:false,
                        pagination:true,     
                        //分页属性
                        keyboard:true,
                        direction:"vertical",
                        //竖屏滑动
                        callback:""
                }
                })(jQuery);